import {
  Form, Icon, Input, Button,
} from 'antd';
import React from 'react';
import { connect } from 'dva';
import styles from './page.css'
class NormalLoginForm extends React.Component {
  handleSubmit = (e) => {
    const { dispatch} = this.props;
    e.preventDefault();
    this.props.form.validateFields((err, values) => {
      if (!err) {
        console.log(values,"====zzzz")
        dispatch({
          type: 'users/login',
          payload: {...values},
        });
      }
    });
  }
  render() {
    const { getFieldDecorator } = this.props.form;
    return (
      <div className={styles.normal}>
        <div style={{paddingBottom:'20px'}}>
          <div>egg代码: <a href='https://gitee.com/atony2099/sign_system'>https://gitee.com/atony2099/sign_system</a> </div>
        <div>前端代码: <a href='https://gitee.com/atony2099/sign_web.git'>https://gitee.com/atony2099/sign_web.git</a> </div>
        </div>
      <Form onSubmit={this.handleSubmit} className="login-form">
        <Form.Item>
          {getFieldDecorator('userName', {
            rules: [{ required: true, message: 'Please input your username!' }],
              initialValue:'admin'
          })(
            <Input prefix={<Icon type="user" style={{ color: 'rgba(0,0,0,.25)' }} />} placeholder="Username" />
          )}
        </Form.Item>
        <Form.Item>
          {getFieldDecorator('password', {
            rules: [{ required: true, message: 'Please input your Password!' }],
              initialValue: 'admin'
          })(
            <Input prefix={<Icon type="lock" style={{ color: 'rgba(0,0,0,.25)' }} />} type="password" placeholder="Password" />
          )}
        </Form.Item>
        <Form.Item>
          <Button type="primary" htmlType="submit" className="login-form-button">
            Log in
          </Button>
        </Form.Item>
      </Form>
      </div>
    );
  }
}

const WrappedNormalLoginForm = Form.create({ name: 'normal_login' })(NormalLoginForm);

export default connect()(WrappedNormalLoginForm);


